package miku.firstgame.model.proxy
{
	import miku.firstgame.net.MikuSocketImpl;
	import miku.firstgame.net.SocketImpl;
	import miku.firstgame.net.proxy.Connection;

	import org.puremvc.as3.patterns.proxy.Proxy;

	public class ConnectionProxy extends Proxy
	{
		public static const NAME:String = "ConnectionProxy";

		private var socket:MikuSocketImpl;

		public function ConnectionProxy(data:MikuSocketImpl)
		{
			super(NAME, data);
			this.socket = data;
		}

		override public function onRegister():void
		{
			super.onRegister();
			initSocket();
		}

		private function initSocket():void
		{
			//socket = new SocketImpl();
			socket.setHandler(new Connection());
			socket.connect("localhost", 9123);
			//socket.connect("localhost", 9123);
			//http://192.168.16.139/starling/testPunk.html
		}

		public function send(value:Object):void
		{
			socket.send(value);
		}
	}
}
